<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title></title>
		<!--写⼀个倒计时的效果，计算从此时此刻到本年12⽉31⽇23点0分0秒相差的天数⼩时数分钟数秒数-->
		<script type="text/javascript">
			window.onload = function(){
				function run(){
					//1.获取当前时间
					var nowTime = new Date();
					//2.获取未来时间
					var fuTime = new Date(2017,11,31,23,0,0);
					//3.未来时间减去当前时间
					var res = fuTime-nowTime;
					//4.天
					var day = parseInt(res/(24*60*60*1000));
					//5.取余 剩余的毫秒数
					var res = res%(24*60*60*1000);
					//6.小时
					var hour = parseInt(res/(60*60*1000));
					var res = res%(60*60*1000);
					//7.分钟
					var min = parseInt(res/(60*1000));
					var res = res%(60*1000);
					//8.秒
					var second = parseInt(res/1000);
					
					var spans = document.getElementsByTagName('span');
					spans[0].innerHTML = day;
					spans[1].innerHTML = hour;
					spans[2].innerHTML = min;
					spans[3].innerHTML = second;
				}
				
				//10
				run();
				//9.执行定时器 
				setInterval(run,1000);
			}
		</script>
	</head>
	<body>
		<h1 id="time">距离2017年12月31号23时0分0秒还有<span>?</span>天<span>?</span>小时<span>?</span>分钟<span>?</span>秒数</h1>
	</body>
</html>
